package com.coship.vasms.adstorm.dao.impl;

import java.util.List;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.coship.vasms.adstorm.dao.AdvertisementDao;
import com.coship.vasms.adstorm.model.Advertisement;

public class AdvertisementDaoImpl implements AdvertisementDao<Advertisement>{
	private SqlMapClientTemplate sqlMapClientTemplate;
	
	public SqlMapClientTemplate getSqlMapClientTemplate() {
		return sqlMapClientTemplate;
	}

	public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) {
		this.sqlMapClientTemplate = sqlMapClientTemplate;
	}
	
	@Override
	public void save(Advertisement ad) {
		// TODO Auto-generated method stub
		sqlMapClientTemplate.insert("insertAd", ad);
	}

	@Override
	public void deleteByid(Integer id) {
		// TODO Auto-generated method stub
		sqlMapClientTemplate.delete("deleteAd", id);
	}


	@Override
	public List<Advertisement> queryAllAd() {
		// TODO Auto-generated method stub
		return (List<Advertisement>)sqlMapClientTemplate.queryForList("getAllAd");
	}

	@Override
	public void update(Advertisement ad) {
		sqlMapClientTemplate.update("updateAd", ad);
		
	}

	@Override
	public Advertisement queryAdvertisementById(Integer id) {
		return (Advertisement)sqlMapClientTemplate.queryForObject("getAdById",id);
	}
}
